package com.appspot.moviesessions.provider;

import java.io.IOException;
import java.io.InputStream;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;

public class HTTPSessionDataSource implements SessionDataSource {

	private HttpClient httpClient;

	public HTTPSessionDataSource(HttpClient client) {
		this.httpClient = client;
	}

	@Override
	public InputStream fetch(String url) {
		try {
			//"http://10.0.2.2:8888/movies"
			HttpResponse response = httpClient.execute(new HttpGet(
			        url));
			return response.getEntity().getContent();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

}
